#!/bin/bash

set +e

[ -d /tmp/.weforge ] || mkdir /tmp/.weforge

/home/layer/bin/php -r "
require __DIR__.'/vendor/autoload.php';

WeForge\Runtime\Secrets::addToEnvironment(
    \$_ENV['WEFORGE_KMS_SECRET_PATH'],
    \$_ENV['WEFORGE_KMS_SECRET_VARIABLES'] ?? '[]'
);
"

[ -f /tmp/.weforge/secrets ] && source /tmp/.weforge/secrets

while true
do
    /home/layer/bin/php ./runtime.php
done
